<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="telephone=no" name="format-detection" />
    <meta content="emai=no" name="format-detection" />
    <link rel="stylesheet" type="text/css" href="/wc/css/common.css" />
    <link rel="stylesheet" type="text/css" href="/wc/css/form.css" />
    <script type="text/javascript" src="/wc/js/jquery-1.11.2.min.js"></script>
    <script type="text/javascript" src="/wc/js/underscore.js"></script>
    <script type="text/javascript" src="/wc/js/pinchzoom.js"></script>
    <title>芝士妈妈在线</title>
    <script type="text/javascript">
        (function (m, ei, q, i, a, j, s) {
            m[a] = m[a] || function () {
                    (m[a].a = m[a].a || []).push(arguments)
                };
            j = ei.createElement(q),
                s = ei.getElementsByTagName(q)[0];
            j.async = true;
            j.charset = 'UTF-8';
            j.src = i + '?v=' + new Date().getUTCDate();
            s.parentNode.insertBefore(j, s);
        })(window, document, 'script', '//static.meiqia.com/dist/meiqia.js', '_MEIQIA');
        _MEIQIA('entId', '20405');
        _MEIQIA('withoutBtn');
        _MEIQIA('init');
    </script>
    <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>

    <script>
        $(function() {
            $("button[type='submit']").click(function (e) {
                e.preventDefault();
                validation();
            });
            
            function validation() {
                zsmm.isValidated = true;
                validateInput("name");
                validateSelect("idcard_type");
                validateInput("cardnumber");
                validateCardNumber("cardnumber", $("#idcard_type").val());
                validateInput("birthday");
                validateInput("duedate");
                validateInput("mobile");
                validatePhone("mobile");
                validateInput("code");
                validateCode("code");
                validateSelect("collection");
//				validateSelect("doctor");                
                
                if (zsmm.isValidated) {
                		console.log('success');
                    //$("form").submit();
                    var name = $("#name").val();
                    var idcard = $("#cardnumber").val();
                    var idcard_type = $("#idcard_type").val();
                    var birthday = $("#birthday").val();
                    var duedate = $("#duedate").val();
                    var mobile = $("#mobile").val();
                    var code = $("#code").val();
                    var collection = $("#collection").val();
//                  var doctor = $("#doctor").val();
                    //ajax更新数据
                    $.ajax({
                        url: "/booking/savedate",
                        type: "post",
                        dataType: "json",
                        data:{
                            'name': name,
                            'idcard':idcard,
                            'idcard_type':idcard_type,
                            'birthday':birthday ,
                            'duedate':duedate,
                            'mobile':mobile,
                            'code':code,
                            'collection':collection
//                          'doctor':doctor
                        },
                        success: function(msg)
                        {
                            window.location.href='/wxpay/?id='+msg.data.id+'&booking_id='+msg.data.booking_id;
                        },
                        error: function (xhr, type)
                        {
                            zsmm.Toast.New("请重试！");
                        },
                    });
                }
            }

			function validateCode(obj){
				if ($.trim($("#" + obj).val()) == "" && zsmm.isValidated) {
					zsmm.Toast.New($("#" + obj).data("message"));
					zsmm.isValidated = false;					
				}
				else{
					var codeID=$.trim($("#" + obj).val());
					//验证码校验
	                $.ajax({
	                    url: "/booking/validcode",
	                    async: false,
	                    data: {mobile: $("#mobile").val(), code: codeID},
	                    type: "post",
	                    dataType: "json",
	                    success: function(res){
	                        if(res.error != 0)
	                        {
	                            zsmm.Toast.New(res.msg);
	                            zsmm.isValidated = false;
	                        }	
	                    }	
	                });
				}
			}

        });

    </script>
</head>
<body>
<header class="nopadding">
    <?php if(@$row['status'] <= 1){}else{echo '<img class="fullScreen" src="/wc/img/d_notice.png" />';} ?>
</header>
<div class="wrapper">
    <input type="hidden" id="id" value="<?php echo $row['id']?>">
    <?php if(@$row['status'] <= 1){echo '<h2>个人信息填写</h2>';}?>
    <section class="flex-wrapper flex-align-center special">
        <label>姓名：</label>
        <p class="flex-1">
            <input type="text" id="name" name="name" value="<?php echo @$row['name']?>" data-message="请输入姓名！" />
        </p>
    </section>
    <section class="flex-wrapper flex-align-center special">
        <label>证件类型：</label>
        <p class="flex-1">
            <select class="special" id="idcard_type" name="idcard_type">
                <option value="1" <?php if(@$row['idcard_type'] == 1) echo 'selected = "selected"' ?> >身份证</option>
                <option value="2" <?php if(@$row['idcard_type'] == 2) echo 'selected = "selected"' ?> >港澳通行证</option>
                <option value="3" <?php if(@$row['idcard_type'] == 3) echo 'selected = "selected"' ?> >台湾通行证</option>
                <option value="4" <?php if(@$row['idcard_type'] == 4) echo 'selected = "selected"' ?> >护照</option>
            </select>
        </p>
    </section>
    <section class="flex-wrapper flex-align-center special">
        <label>证件号码：</label>
        <p class="flex-1">
            <input type="text" id="cardnumber" name="cardnumber" value="<?php echo @$row['idcard']?>" data-message="请输入证件号码！" />
        </p>
    </section>
    <section class="flex-wrapper flex-align-center special">
        <label>出生年月：</label>
        <p class="flex-1">
            <input type="date" id="birthday" name="birthday" value="<?php echo @$row['birthday']?>" data-message="请输入出生年月！" />
        </p>
    </section>
    <section class="flex-wrapper flex-align-center special">
        <label>预产期：</label>
        <p class="flex-1">
            <input type="date" id="duedate" name="duedate" value="<?php echo @$row['childbirth_date']?>" data-message="请输入预产期！" />
        </p>
    </section>
    <section class="flex-wrapper flex-align-center special">
        <label>手机号：</label>
        <p class="flex-1">
            <input type="tel" maxlength="13" id="mobile" name="mobile" value="<?php echo @$row['mobile']?>" data-message="请输入手机号！" />
        </p>
    </section>
    <section class="flex-wrapper flex-align-center nopadding">
        <label><button type="button" id="geticode" name="geticode" class="special">获取验证码</button></label>
        <p class="flex-1">
            <input type="number" maxlength="6" id="code" name="code" value="" placeholder="请输入验证码" data-message="请输入验证码！" />
        </p>
    </section>
    <h2>采血点</h2>
    <section class="nopadding">
        <select class="special" id="collection" name="collection">
            <?php foreach($bpointList as $key=>$value) { ?>
                <option value="<?php echo $value['id'] ?>" <?php if(@$row['bpoint_id'] == $value['id']) echo 'selected = "selected"' ?>><?php echo $value['name'] ?></option>
            <?php } ?>

        </select>
    </section>
    <!--<h2>推荐医生</h2>
		<section class="nopadding">
			<select class="special" id="doctor" name="doctor">
				<?php foreach($doctorList as $key=>$value) { ?>
					<option value="<?php echo $value['d_id'] ?>"  <?php if(@$row['doctor_id'] == $value['id']) echo 'selected = "selected"' ?>><?php echo $value['real_name'] ?></option>
				<?php } ?>
			</select>
			<p class="notice">（提示：您的推荐医生将第一时间获取您的检测状态）</p>
		</section>-->
    <h2>预约费用：&yen;200.00元</h2>
    <p class="notice">（凭预约单手机号码可直接抵扣检测费用）</p>
    <button type="submit" class="btn btn-red" id="savedate">付款预约</button>

    <?php if(@$row['status'] <= 1){}else{echo '<ul class="help flex-wrapper flex-pack-justify">
			<li><a href="javascript:void(0)" onclick="_MEIQIA(\'showPanel\')"><img src="/wc/img/d_online.png" /></a></li>
			<li><a href="tel:4008210418"><img src="/wc/img/d_phone.png" /></a></li>
		</ul>';} ?>


</div>
<footer>
    <ul>
        <li>
            <a href="/booking" class="btn btn-orange"><span class="icon icon-home"></span>首 页</a>
        </li>
        <li>
            <a id="showMap" class="btn btn-green"><span class="icon icon-blood"></span>采 血 点</a>
        </li>
        <li>
            <a href="/booking/mine" class="btn btn-red"><span class="icon icon-test"></span>我的检测</a>
        </li>
    </ul>

</footer>
<div class="hide popup-map">
    <div class="pinch-zoom">
        <img src="/wc/img/map.jpg" alt="" />
    </div>
</div>
<script src="/wc/js/common.js" type="text/javascript"></script>
<script src="/wc/js/form.js" type="text/javascript"></script>
</body>
</html>
